<template>
  <div class="table-layout">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-row>
        <el-col span=6>
          <el-form-item label="品种" prop="type">
            <el-input v-model="form.mainObj.type" />
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="产品编号" prop="productno">
            <el-input v-model="form.mainObj.productno"/>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="生产数量" prop="productcount">
            <el-input v-model="form.mainObj.productcount" />
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="交货期" prop="deadline">
            <el-date-picker clearable size="small"
                            v-model="form.mainObj.deadline"
                            type="date"
                            value-format="yyyy-MM-dd"
                            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row align="center">
        <el-col>
          <h3 align="center">整经工序</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=6>
          <el-form-item label="总经根数" prop="totalnumber">
            <el-input v-model="form.warpingObj.totalnumber"/>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="经纱纱支" prop="yarncount">
            <el-input v-model="form.warpingObj.yarncount"/>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="机器型号" prop="machinetype">
            <el-input v-model="form.warpingObj.machinetype"/>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="卷绕速度" prop="windingspeed">
            <el-input v-model="form.warpingObj.windingspeed">
              <i slot="suffix" style="margin-right: 10px;">m/min</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=6>
          <el-form-item label="根数*轴数" prop="numberbeam">
            <el-input v-model="form.warpingObj.numberbeam">
              <i slot="suffix" style="margin-right: 10px;">根*只</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="整经长度" prop="warpinglength">
            <el-input v-model="form.warpingObj.warpinglength">
              <i slot="suffix" style="margin-right: 10px;">m</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="经纱用纱量" prop="warpnumber">
            <el-input v-model="form.warpingObj.warpnumber">
              <i slot="suffix" style="margin-right: 10px;">kg/hm</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="经纱用纱总量" prop="warptotalnumber">
            <el-input v-model="form.warpingObj.warptotalnumber">
              <i slot="suffix" style="margin-right: 10px;">T</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row align="center">
        <el-col>
          <h3 align="center">穿综筘工序</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=3>
          <el-form-item label="综框页数" prop="framenumber">
            <el-input v-model="form.loomingObj.framenumber">
              <i slot="suffix" style="margin-right: 10px;">页</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="筘号" prop="reedcount">
            <el-input v-model="form.loomingObj.reedcount">
              <i slot="suffix" style="margin-right: 10px;">号</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="穿筘幅宽" prop="reedwidth">
            <el-input v-model="form.loomingObj.reedwidth">
              <i slot="suffix" style="margin-right: 10px;">cm</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="机型" prop="machinetype">
            <el-input v-model="form.loomingObj.machinetype"/>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="边纱根数" prop="edgeyarnnumber">
            <el-input v-model="form.loomingObj.edgeyarnnumber"/>
          </el-form-item>
        </el-col>
        <el-col span=8>
          <el-form-item label="每列综丝数" prop="healdnumber">
            <el-input v-model="form.loomingObj.healdnumber"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=3>
          <el-form-item label="地综穿入数" prop="groundframe">
            <el-input v-model="form.loomingObj.groundframe">
              <i slot="suffix" style="margin-right: 10px;">根</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="边综穿入数" prop="edgeframe">
            <el-input v-model="form.loomingObj.edgeframe">
              <i slot="suffix" style="margin-right: 10px;">根</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="地筘插入数" prop="groundreed">
            <el-input v-model="form.loomingObj.groundreed">
              <i slot="suffix" style="margin-right: 10px;">根</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="边筘插入数" prop="edgereed">
            <el-input v-model="form.loomingObj.edgereed">
              <i slot="suffix" style="margin-right: 10px;">根</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="综穿法地组织" prop="groundweave">
            <el-input v-model="form.loomingObj.groundweave"/>
          </el-form-item>
        </el-col>
        <el-col span=3>
          <el-form-item label="综穿法边组织" prop="edgeweave">
            <el-input v-model="form.loomingObj.edgeweave"/>
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="停经片穿法" prop="dropwire">
            <el-input v-model="form.loomingObj.dropwire"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row align="center">
        <el-col>
          <h3 align="center">浆纱配方</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="PRS-C" prop="prsc">
            <el-input v-model="form.formulaObj.prsc">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="PVA-1799" prop="pva1799">
            <el-input v-model="form.formulaObj.pva1799">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="天美胶料" prop="sizingmaterial">
            <el-input v-model="form.formulaObj.sizingmaterial">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="变性淀粉" prop="modifiedstarch">
            <el-input v-model="form.formulaObj.modifiedstarch">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="ADC" prop="adc">
            <el-input v-model="form.formulaObj.adc">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="蜡片" prop="waxscale">
            <el-input v-model="form.formulaObj.waxscale">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="抗静电剂" prop="antistatic">
            <el-input v-model="form.formulaObj.antistatic">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="防腐剂" prop="antiseptic">
            <el-input v-model="form.formulaObj.antiseptic">
              <i slot="suffix" style="margin-right: 10px;">kg</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="乳化油" prop="emulsifiedoil">
            <el-input v-model="form.formulaObj.emulsifiedoil">
              <i slot="suffix" style="margin-right: 10px;">块</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="浆液类型" prop="sizetype">
            <el-input v-model="form.formulaObj.sizetype">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="定积/高度" prop="volumeheight">
            <el-input v-model="form.formulaObj.volumeheight">
              <i slot="suffix" style="margin-right: 10px;">L/cm</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="含固率" prop="solidcontent">
            <el-input v-model="form.formulaObj.solidcontent">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="供应桶温度" prop="supplytemp">
            <el-input v-model="form.formulaObj.supplytemp">
              <i slot="suffix" style="margin-right: 10px;">℃</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="供应桶粘度" prop="supplyvis">
            <el-input v-model="form.formulaObj.supplyvis">
              <i slot="suffix" style="margin-right: 10px;">s</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="供应PH值" prop="supplyph">
            <el-input v-model="form.formulaObj.supplyph">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="使用时间" prop="usedtime">
            <el-input v-model="form.formulaObj.usedtime">
              <i slot="suffix" style="margin-right: 10px;">h</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="覆盖系数" prop="covering">
            <el-input v-model="form.formulaObj.covering">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="浆用成本" prop="cost">
            <el-input v-model="form.formulaObj.cost">
              <i slot="suffix" style="margin-right: 10px;">元/百米</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row align="center">
        <el-col>
          <h3 align="center">浆纱工艺</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="机器型号" prop="machinetype">
            <el-input v-model="form.processObj.machinetype">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="并缸轴数" prop="cylindernumber">
            <el-input v-model="form.processObj.cylindernumber">
              <i slot="suffix" style="margin-right: 10px;">只</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="织轴开档" prop="beamopening">
            <el-input v-model="form.processObj.beamopening">
              <i slot="suffix" style="margin-right: 10px;">cm</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="墨印长度" prop="inklength">
            <el-input v-model="form.processObj.inklength">
              <i slot="suffix" style="margin-right: 10px;">m</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="墨印颜色" prop="inkcolor">
            <el-input v-model="form.processObj.inkcolor"></el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="后上蜡" prop="waxing">
            <el-input v-model="form.processObj.waxing">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="上浆率" prop="sizingpersent">
            <el-input v-model="form.processObj.sizingpersent">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="回潮率" prop="moistureregain">
            <el-input v-model="form.processObj.moistureregain">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="伸长率" prop="elongation">
            <el-input v-model="form.processObj.elongation">
              <i slot="suffix" style="margin-right: 10px;">%</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="浆槽温度" prop="temperature">
            <el-input v-model="form.processObj.temperature">
              <i slot="suffix" style="margin-right: 10px;">℃</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="浆槽粘度" prop="viscosity">
            <el-input v-model="form.processObj.viscosity">
              <i slot="suffix" style="margin-right: 10px;">℃</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="浆槽PH值" prop="ph">
            <el-input v-model="form.processObj.ph"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col span=4>
          <el-form-item label="卷绕线速度" prop="windingspeed">
            <el-input v-model="form.processObj.windingspeed">
              <i slot="suffix" style="margin-right: 10px;">m/min</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="张力调节" prop="tensionadjust">
            <el-input v-model="form.processObj.tensionadjust"/>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="压浆辊压力" prop="force">
            <el-input v-model="form.processObj.force">
              <i slot="suffix" style="margin-right: 10px;">KN</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="预烘温度" prop="pretemp">
            <el-input v-model="form.processObj.pretemp">
              <i slot="suffix" style="margin-right: 10px;">℃</i>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span=4>
          <el-form-item label="烘燥温度" prop="dryingtemp">
            <el-input v-model="form.processObj.dryingtemp">
              <i slot="suffix" style="margin-right: 10px;">℃</i>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-form-item label="要求" prop="request">
          <el-input v-model="form.processObj.request" type="textarea" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-col span=6>

        </el-col>
        <el-col span=6>

        </el-col>
        <el-col span=6>
          <el-form-item label="浆纱工程师" prop="sizingname ">
            <el-input v-model="form.mainObj.sizingname" />
          </el-form-item>
        </el-col>
        <el-col span=6>
          <el-form-item label="工艺设计人员" prop="designname">
            <el-input v-model="form.mainObj.designname" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
    import {listGy_main, getGy_main, delGy_main, addGy_main, updateGy_main, exportGy_main} from "@/api/gongyi/gy_main";

    export default {
        name: "Gy_main",
        data() {
            return {

                showdata: Object,
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 工艺设计主表表格数据
                gy_mainList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 查询参数

                // 表单参数
                form: {
                    mainObj: {
                        id: null,
                        type: null,
                        productno: null,
                        productcount: null,
                        deadline: null,
                        warpingId: null,
                        loomingId: null,
                        formulaId: null,
                        processId: null,
                        sizingname: null,
                        designname: null,
                        createTime: null,
                        updateTime: null
                    },
                    warpingObj: {
                        id: null,
                        totalnumber: null,
                        yarncount: null,
                        machinetype: null,
                        windingspeed: null,
                        numberbeam: null,
                        warpinglength: null,
                        warpnumber: null,
                        warptotalnumber: null,
                        createTime: null,
                        updateTime: null
                    },
                    loomingObj: {
                        id: null,
                        framenumber: null,
                        reedcount: null,
                        reedwidth: null,
                        groundframe: null,
                        edgeframe: null,
                        groundreed: null,
                        edgereed: null,
                        groundweave: null,
                        edgeweave: null,
                        dropwire: null,
                        healdnumber: null,
                        machinetype: null,
                        edgeyarnnumber: null,
                        createTime: null,
                        updateTime: null
                    },
                    formulaObj: {
                        id: null,
                        prsc: null,
                        pva1799: null,
                        sizingmaterial: null,
                        modifiedstarch: null,
                        adc: null,
                        waxscale: null,
                        antistatic: null,
                        antiseptic: null,
                        emulsifiedoil: null,
                        sizetype: null,
                        volumeheight: null,
                        solidcontent: null,
                        supplytemp: null,
                        supplyvis: null,
                        supplyph: null,
                        usedtime: null,
                        covering: null,
                        cost: null,
                        createTime: null,
                        updateTime: null
                    },
                    processObj: {
                        id: null,
                        machinetype: null,
                        cylindernumber: null,
                        beamopening: null,
                        inklength: null,
                        inkcolor: null,
                        waxing: null,
                        sizingpersent: null,
                        moistureregain: null,
                        elongation: null,
                        temperature: null,
                        viscosity: null,
                        ph: null,
                        windingspeed: null,
                        tensionadjust: null,
                        force: null,
                        pretemp: null,
                        dryingtemp: null,
                        request: null,
                        createTime: null,
                        updateTime: null
                    }
                },
                // 表单校验
                rules: {}
            };
        },
        created() {
            this.getList();
        },
        methods: {
            /** 查询工艺设计主表列表 */
            getList() {

               let mainID = this.$route.query.id;
               if (mainID != null){
                   getGy_main(mainID).then(response => {
                       this.form = response.data;
                       console.log(this.form)
                   });
               }

            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    mainObj: {
                        id: null,
                        type: null,
                        productno: null,
                        productcount: null,
                        deadline: null,
                        warpingId: null,
                        loomingId: null,
                        formulaId: null,
                        processId: null,
                        sizingname: null,
                        designname: null,
                        createTime: null,
                        updateTime: null
                    },
                    warpingObj: {
                        id: null,
                        totalnumber: null,
                        yarncount: null,
                        machinetype: null,
                        windingspeed: null,
                        numberbeam: null,
                        warpinglength: null,
                        warpnumber: null,
                        warptotalnumber: null,
                        createTime: null,
                        updateTime: null
                    },
                    loomingObj: {
                        id: null,
                        framenumber: null,
                        reedcount: null,
                        reedwidth: null,
                        groundframe: null,
                        edgeframe: null,
                        groundreed: null,
                        edgereed: null,
                        groundweave: null,
                        edgeweave: null,
                        dropwire: null,
                        healdnumber: null,
                        machinetype: null,
                        edgeyarnnumber: null,
                        createTime: null,
                        updateTime: null
                    },
                    formulaObj: {
                        id: null,
                        prsc: null,
                        pva1799: null,
                        sizingmaterial: null,
                        modifiedstarch: null,
                        adc: null,
                        waxscale: null,
                        antistatic: null,
                        antiseptic: null,
                        emulsifiedoil: null,
                        sizetype: null,
                        volumeheight: null,
                        solidcontent: null,
                        supplytemp: null,
                        supplyvis: null,
                        supplyph: null,
                        usedtime: null,
                        covering: null,
                        cost: null,
                        createTime: null,
                        updateTime: null
                    },
                    processObj: {
                        id: null,
                        machinetype: null,
                        cylindernumber: null,
                        beamopening: null,
                        inklength: null,
                        inkcolor: null,
                        waxing: null,
                        sizingpersent: null,
                        moistureregain: null,
                        elongation: null,
                        temperature: null,
                        viscosity: null,
                        ph: null,
                        windingspeed: null,
                        tensionadjust: null,
                        force: null,
                        pretemp: null,
                        dryingtemp: null,
                        request: null,
                        createTime: null,
                        updateTime: null
                    }



                };
                this.resetForm("form");
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.id)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加工艺设计主表";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids
                getGy_main(id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改工艺设计主表";
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.mainObj.id != null) {
                            updateGy_main(this.form).then(response => {
                                this.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            });
                        } else {
                            addGy_main(this.form).then(response => {
                                this.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            });
                        }
                    }
                });
            },

        }
    };
</script>

<style rel="stylesheet/scss" lang="scss">
  .table-layout {
    margin-top: 10px;
    width: 99%;
    display: table;
    margin-left: 10px;
  }

  .trow {
    align-items: center;
    justify-content: center;
    display: flex;
  }

  .tcell {
    border: 1px solid #001528;
    align-content: center;
  }

</style>
